// 审核弹窗组件
<template>
  <el-dialog
    class="audit-dialog"
    :visible="dialogVisible"
    @close="closeDialog"
    width="500px"
  >
    <template slot="title">
      <div
        v-if="isReject"
        class="audit-dialog-title">
        驳回
      </div>
      <div
        v-else
        class="audit-dialog-title">
        通过
      </div>
    </template>
    <div class="audit-form-wrapper">
      <el-form
        :model="auditForm"
        :rules="auditFormRules"
        ref="auditForm">
        <el-form-item
          label="关联发票号"
          prop="invoice"
          v-if="showInvoice">
          <el-input
            v-model="auditForm.invoice"
          />
        </el-form-item>
        <el-form-item
          label="备注"
          prop="remark"
        >
          <el-input
            type="textarea"
            v-model="auditForm.remark"
          />
        </el-form-item>
      </el-form>
    </div>
    <template slot="footer">
      <el-button
        type="primary"
        :loading="loading"
        @click="submitAudit">
        确定</el-button>
    </template>
  </el-dialog>
</template>

<script>
export default {
  name: 'AuditDialog',
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    isReject: {
      type: Boolean,
      default: false
    },
    showInvoice: { // 是否显示关联发票
      type: Boolean,
      default: false
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      auditForm: {
        invoice: '',
        remark: ''
      },
      auditFormRules: {}
    }
  },
  methods: {
    submitAudit () {
      this.$emit('submitAudit', this.auditForm)
    },
    closeDialog () {
      this.auditForm = {}
      this.$emit('closeDialog')
    }
  }
}
</script>

<style scoped>

</style>
